package com.ordertracker.client;

import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.core.util.MultivaluedMapImpl;
import com.sun.jersey.oauth.client.OAuthClientFilter;
import com.sun.jersey.oauth.signature.OAuthParameters;
import com.sun.jersey.oauth.signature.OAuthSecrets;

import javax.ws.rs.core.MultivaluedMap;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * Description of class.
 * Created 2/19/13 1:34 PM
 *
 * @author andrey.rodin@playtech.com
 */

public class OAuthClient {

    public static void main(String[] args) {
        Client client = Client.create();
        OAuthSecrets secrets = new OAuthSecrets().consumerSecret("secret");
        OAuthParameters parameters = new OAuthParameters().consumerKey("keySecret").signatureMethod("HMAC-SHA1").timestamp().nonce().version("1.0");
        OAuthClientFilter filter = new OAuthClientFilter(client.getProviders(), parameters, secrets);
        MultivaluedMap<String, String> queryParam = new MultivaluedMapImpl();
        queryParam.add("param1","smugmug.auth.getRequestToken");
        queryParam.add("param2","asn");

        WebResource resource = client.resource("http://localhost:8080/rest/service/helloworld").queryParams(queryParam);
        resource.addFilter(filter);
        String resp = resource.type("application/json").get(String.class);
        System.out.println(resp);

    }

}
